package uml.behavioral.mediator;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 中介者--具体中介者<br>
 * on 2023/1/2 22:27
 */
public class QQGroup extends Mediator {

    public QQGroup(String name) {
        super(name);
    }

    @Override
    public void chatInGroup() {
        System.out.println("【"+this.getName()+"】[" + new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss").format(new Date()) + "] "
                + this.getMsgSender().getName() + " 【发送】消息：" + this.getMsgSender().getMsg());
        for (User user : users) {
            if (this.getMsgSender() != user) {
                System.out.println("【"+this.getName()+"】[" + new SimpleDateFormat("yyyy年MM月dd日 hh:mm:ss").format(new Date()) + "] "
                        + user.getName() + " 【收到】消息：" + this.getMsgSender().getMsg());
            }
        }
        System.out.println();
    }
}
